import time

from NanNing.common import UdpClient, RadarTEST


# FormatValidation
class FormatVal:
    CRSError = '15003dc7112b49800c00290016661d4a9c3c0b330e8e254e1e0b000bb9f4060101060002e12038353530c30c40'
    LostTime = '15002dc7112b49800c00290016661d4a9c3c0b330e8e254e1e0b000bb9f4060101060002e12038353530c30c40'
    # Lost /040 & /042
    Lost042And040 = '030330003eeff7021658177000a0046405046003c1780c2c0d30f8d77ce003beb00030aa000040c35a3330bfe000608018533be014e950064b088d853b4022f5'
    # 格式错误
    FormatError = '150034c71d2b49800c00290016661d4a9c3c0b330e8e254e1e0b000bb9065a1f0008076bf4060101060002e12038353530c30c40'
    # lost targetaddress
    LostTargetAddr = '150031c70d2b49800c00290016661d4a9c3c0b330e8e254e1e0b065a1f0008076bf4060101060002e12038353530c30c40'
    #
    LostReport = '150032871d2b49800c0016661d4a9c3c0b330e8e254e1e0b000bb9065a1f0008076bf4060101060002e12038353530c30c40'
    TooHeight = '150038c71d3b49800c00290016661d4a9c3c0b330e8e254e1e0b000bb9065a1f0008076bf149ff5008060101060002e12038353530c30c40'


if __name__ == '__main__':
    try:
        with UdpClient() as client:
            tag = 0
            while True:
                tag += 1
                print(f"-------------------------------------------------------------------------\n"
                      f"sending message {tag}")
                client.set_data(FormatVal.Lost042And040)
                client.get_data_type()
                client.connect(RadarTEST.HOST, RadarTEST.PORT2)
                # client.send()
                client.main_send(is_print_log=True, is_send_sector=True, is_send_north=True)

                time.sleep(4)
                print("-------------------------------------------------------------------------\n")

    except KeyboardInterrupt:
        print("-------------------------------------------------------------------------\n")
        print("程序被中断")
